<?php
$this->Html->addCrumb('Image Gallery', '/gallery-'.$this->layout);
if($this->layout==='admin') {
  $this->Html->addCrumb('Albums', '/admin/categories');
}
$this->Html->addCrumb('Edit');
$this->Html->scriptStart(array('inline' => false));
echo '
      $(function(){
        $("#Album'.ucfirst($this->layout).'EditForm").TWS_Form( {
          validate : {
          rules : {
            AlbumName : {required : true, help : "This is the name of the album"},
            AlbumCategoryId : {help : "This is the category the album belongs to", required : true}
          }
          }});
       
         $("#deleteBtn").click(function(event){
          if(!$("#deleteBtn").attr("data-delete-confirm")) {
          $("#deleteBtn").attr("data-delete-confirm","");
            $.TWS_Overlay("confirm", {title : "Delete confirmation", message : "Are you sure you want to delete this record?", buttons : {ok :{onclick : function () { $.TWS_Overlay("hide"); $("#deleteBtn").attr("data-delete-confirm",true).trigger("click");}}}});
            event.preventDefault();
          }
        });
         });
       ';
$this->Html->scriptEnd();

?>


<h1>Edit Album</h1>
<?php echo $this->Session->flash();?>
<?php echo '<div id="actionLink">'.$this->Html->link('Back to list of Albums',array('action'=>'index', $this->layout=>true)).'</div>'; ?>

<?php echo $this->element('errors', array('errors' => isset($errors)? $errors : null)); ?>
<?php

echo $this->TWSForm->create('Album',  array(
    'inputDefaults' => array(
        'div' => array('class'=>'row')),
        'class'=>'inlineForm',
        'type'=>'file'));
echo $this->TWSForm->input('category_id', array('name'=>'AlbumCategoryId', 'type'=>'select', 'label'=>'Category', 'options'=>$options));
echo $this->TWSForm->input('name', array('name'=>'AlbumName', 'type'=>'text','size'=>'63','label'=>'<span class="required">*</span>Name'));
echo $this->TWSForm->input('description', array('rows'=>'5','cols'=>'60','name'=>'AlbumDescription'));
echo $this->TWSForm->submit('Update', array('id'=>'editBtn', 'name'=>'editBtn', 'class'=>'button', 'div'=>false));
echo $this->TWSForm->submit("Delete", array('id'=>'deleteBtn','name'=>'deleteBtn', 'class'=>'button', 'div'=>false));
echo $this->TWSForm->end();

?>